import { useModel } from "umi";

import AddCommoditiesClass from "../components/commoditiesclass/Add";
import AddLowerCommoditiesClass from "../components/commoditiesclass/AddLower";

const useHelperCommoditiesClass = () => {
	const { setModalVisible, setModalTitle, setModalWidth, setModalComponent } = useModel("global.modal");

	const openCreateCommoditiesClassModal = ({ reloadData }) => {
		setModalTitle("新增商品分类");
		setModalVisible(true);
		setModalWidth(500);
		setModalComponent(<AddCommoditiesClass reloadData={reloadData} />);
	};

	const openCreateLowerCommoditiesClassModal = async ({ reloadData, classify }) => {
		setModalTitle("新增下级商品分类");
		setModalVisible(true);
		setModalWidth(500);
		setModalComponent(<AddLowerCommoditiesClass reloadData={reloadData} classify={classify} />);
	};

	return { openCreateCommoditiesClassModal, openCreateLowerCommoditiesClassModal };
};

export default useHelperCommoditiesClass;
